package com.bianxianmao.duobao.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.TextView;

import com.bianxianmao.R;
import com.youth.banner.Banner;


/**
 * Created by Administrator on 2017/7/21.
 */

public class DetailActivity extends Activity implements View.OnClickListener {
    private Context mContext;
    private LinearLayout llDanmu;
    private ImageView ivIcon;
    private ImageView ivBack;
    private Banner banner;
    private TextView tvPeriods;
    private TextView tvTitle;
    private ProgressBar pb;
    private TextView tvAllnumber;
    private TextView tvSurplusnumbeer;
    private TextView tvMyrecord;
    private TextView tvDetail;
    private TextView tvShare;
    private TextView tvRecord;
    private TextView tvKnown;
    private LinearLayout llGood1;
    private ProgressBar pb1;
    private TextView surbplus1;
    private LinearLayout llGood2;
    private ImageView ivGood;
    private ProgressBar pb2;
    private TextView surbplus2;
    private LinearLayout llGood3;
    private ImageView ivGood3;
    private ProgressBar pb3;
    private TextView surbplus3;
    private Button btnRecharge1;
    private Dialog bottomDialog;


    private Button btnMinus;
    private EditText etCount;
    private Button btnPlus;
    private RadioButton rbNumber1;
    private RadioButton rbNumber2;
    private RadioButton rbNumber3;
    private RadioButton rbWraptail;
    private TextView tvTotal;
    private Button btnRecharge;
    private String etcount;
    private String number1;
    private String number2;
    private String number3;
    private String wraptail;
    private TextView tvprice;
    private String price;
    private String total;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner_detail);
        initView();
        initListener();

    }

    private void initView() {
        llDanmu = (LinearLayout) findViewById(R.id.ll_danmu);
        ivIcon = (ImageView) findViewById(R.id.iv_icon);
        ivBack = (ImageView) findViewById(R.id.iv_back);
        banner = (Banner) findViewById(R.id.banner);
        tvPeriods = (TextView) findViewById(R.id.tv_periods);
        tvTitle = (TextView) findViewById(R.id.tv_title);
        pb = (ProgressBar) findViewById(R.id.pb);
        tvAllnumber = (TextView) findViewById(R.id.tv_allnumber);
        tvSurplusnumbeer = (TextView) findViewById(R.id.tv_surplusnumber);
        tvMyrecord = (TextView) findViewById(R.id.tv_myrecord);
        tvDetail = (TextView) findViewById(R.id.tv_detail);
        tvShare = (TextView) findViewById(R.id.tv_share);
        tvRecord = (TextView) findViewById(R.id.tv_record);
        tvKnown = (TextView) findViewById(R.id.tv_known);
        llGood1 = (LinearLayout) findViewById(R.id.ll_good1);
        pb1 = (ProgressBar) findViewById(R.id.pb1);
        surbplus1 = (TextView) findViewById(R.id.surbplus1);
        llGood2 = (LinearLayout) findViewById(R.id.ll_good2);
        ivGood = (ImageView) findViewById(R.id.iv_good);
        pb2 = (ProgressBar) findViewById(R.id.pb2);
        surbplus2 = (TextView) findViewById(R.id.surbplus2);
        llGood3 = (LinearLayout) findViewById(R.id.ll_good3);
        ivGood3 = (ImageView) findViewById(R.id.iv_good3);
        pb3 = (ProgressBar) findViewById(R.id.pb3);
        surbplus3 = (TextView) findViewById(R.id.surbplus3);
        btnRecharge = (Button) findViewById(R.id.btn_recharge);
    }

    private void initListener() {
        ivBack.setOnClickListener(this);
        tvDetail.setOnClickListener(this);
        tvShare.setOnClickListener(this);
        tvRecord.setOnClickListener(this);
        tvKnown.setOnClickListener(this);
        btnRecharge.setOnClickListener(this);
        llGood1.setOnClickListener(this);
        llGood2.setOnClickListener(this);
        llGood3.setOnClickListener(this);
    }

    //显示dialog
    private void showdialog() {
        bottomDialog = new Dialog(this, R.style.BottomDialog);
        View contentView = LayoutInflater.from(this).inflate(R.layout.duobao_dialog, null);

        btnMinus = (Button) contentView.findViewById(R.id.btn_minus);
        etCount = (EditText) contentView.findViewById(R.id.et_count);
        btnPlus = (Button) contentView.findViewById(R.id.btn_plus);
        rbNumber1 = (RadioButton) contentView.findViewById(R.id.rb_number1);
        rbNumber1 = (RadioButton) contentView.findViewById(R.id.rb_number2);
        rbNumber2 = (RadioButton) contentView.findViewById(R.id.rb_number3);
        rbNumber3 = (RadioButton) contentView.findViewById(R.id.rb_wraptail);
        tvTotal = (TextView) contentView.findViewById(R.id.tv_total);
        btnRecharge1 = (Button) contentView.findViewById(R.id.btn_recharge);
        tvprice = (TextView) contentView.findViewById(R.id.price);


//        btnMinus.setOnClickListener( this );
//        btnPlus.setOnClickListener( this );
//        rbNumber1.setOnClickListener( this );
//        rbNumber2.setOnClickListener( this );
//        rbNumber3.setOnClickListener( this );
//        rbWraptail.setOnClickListener( this );
//        btnRecharge1.setOnClickListener( this );

        bottomDialog.setContentView(contentView);
        ViewGroup.LayoutParams layoutParams = contentView.getLayoutParams();
        layoutParams.width = getResources().getDisplayMetrics().widthPixels;
        contentView.setLayoutParams(layoutParams);
        bottomDialog.getWindow().setGravity(Gravity.BOTTOM);
        bottomDialog.show();

//        etcount = etCount.getText().toString();
//        number1 = rbNumber1.getText().toString();
//        number2 = rbNumber2.getText().toString();
//        number3 = rbNumber3.getText().toString();
//        wraptail = rbWraptail.getText().toString();
//        price = tvprice.getText().toString();
//        total = tvTotal.getText().toString();

    }

    //显示登录dialog
    private void showlogindialog() {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_back://返回
                finish();
                break;
            case R.id.tv_detail://图文详情
                startActivity(new Intent(mContext, ImageTextActivity.class));

                break;
            case R.id.tv_share://晒单分享
                startActivity(new Intent(mContext, ShowListandShareActivity.class));
                break;
            case R.id.tv_record://本期参与记录
                startActivity(new Intent(mContext, HistoryrecordsActivity.class));
                break;
            case R.id.tv_known://本期揭晓
                startActivity(new Intent(mContext, AnounceActivity.class));
                break;
            case R.id.btn_recharge://立即夺宝
//                if (islogin){
//                    showdialog();
//                }else {
//                    showlogindialog();
//                }
                showdialog();

                break;
            case R.id.btn_plus:
//                int counter = Integer.parseInt(etcount);
//                counter++;
//                total= counter

                break;
            case R.id.btn_minus:
//                int counter1= Integer.parseInt(etcount);
//                counter1--;
                break;

            case R.id.rb_number1:
//                etCount.setText(number1);
                break;
            case R.id.rb_number2:
//                etCount.setText(number2);
                break;
            case R.id.rb_number3:
//                etCount.setText(number3);
                break;
            case R.id.rb_wraptail:
//                etCount.setText(getSurplusnumber());
                break;
            case R.id.btn_recharge1:
                break;

        }
    }
}
